<?php
namespace Swoole\Registry;
use Swoole\Socket\SocketClient;
use Swoole\Socket\IClient;
use Common\Log;
class RegistryClient extends SocketClient implements IClient{
    private $data;
    public $connecting = false;
    //private $client;
    function __construct($host, $port){
        parent::__construct($this, $host, $port);
        //$this->client = new SocketClient($this, $host, $port);
    }
    
    public function connect(){
        if($this->connecting == false){
            $this->connecting = true;
            parent::connect();
        }
        
        //$this->client->connect();
    }
    public function setSendData($data){
        $this->data = $data;
    } 
    public function onConnect($cli){
        Log::info("RegistryClient onConnect {$this->host} : {$this->port}");
        
        if(empty($data) == false){
            $cli->send($this->data . "\r\n");
        }
    }
    public function onReceive($cli, $data){
        
    }
    public function onError($cli){
        $this->connecting = false;
    }
    public function onClose($cli){
        $this->connecting = false;
    }
}
?>